<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>while语句</title>
    <script>

       //1 ~ 100 求和  5050

        var sum = 0;
        var num = 1;

        while(num <= 100){
            sum += num;
            num ++;
        }
        alert(sum);

    </script>
</head>
<body>

</body>
</html>